home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch18 / rtrace / chem2scn.awk < prev    next >
Text File  |  1993-07-05  |  614b  |  29 lines

  1. BEGIN {
  2.   printf "#define X 10\n"
  3.   printf "#include \"chem.h\"\n"
  4. }
  5. /^atomlocation/ {
  6.   printf "sphere s%d %g %g %g %g\n", $11, $4 / 1300.0, $5 / 1300.0, \
  7.   $6 / 1300, $7
  8.   atomx[$2] = $4 / 1300.0
  9.   atomy[$2] = $5 / 1300.0
  10.   atomz[$2] = $6 / 1300.0
  11.   atoms++
  12.   next
  13. }
  14. /^chemical / {
  15.   if ($3 > $NF) next
  16.   if ($3 < 1 || $3 > atoms) {
  17.     print "bad input data"
  18.     exit
  19.   }
  20.   if ($NF < 1 || $NF > atoms) {
  21.     print "bad input data"
  22.     exit
  23.   }
  24.   printf "cylinder open s0 %g %g %g %g %g %g RAD\n", \
  25.   atomx[$3], atomy[$3], atomz[$3], \
  26.   atomx[$NF], atomy[$NF], atomz[$NF]
  27.   next
  28. }
  29.